import logging
import asyncio

from pyppeteer import launch

from src.common.mem_data import MemData

LOG = logging.getLogger()


class OpenBrowser(object):
    def __init__(self):
        self.browser = None
        self.params = {
            'headless': False,
            'autoClose': False,
            'userDataDir': 'D:\pyppeteer_userdata',
            'args': ['--disable-infobars', '--window-size=1920,1080', '--no-sandbox']
        }

    async def open_browser(self):
        self.browser = await launch(self.params)
        MemData.browser = self.browser
        LOG.info('browser opened')

    async def run(self):
        await self.open_browser()
